package display2012;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import interfaces.IDisplay;

public class DisplaySwing implements IDisplay {

	private JTextField value;
	private JTextArea log;
	private JButton button;

	public DisplaySwing() {
		configure();
	}

	private void configure() {
		configureValue();
		configureButton();
		configureLogger();
		configureWindow();
	}

	private void configureValue() {
		value = new JTextField("not initialized");
		value.setEditable(false);
	}

	private void configureButton() {
		button = new JButton("Increment");
	}

	private void configureLogger() {
		log = new JTextArea();
	}

	private void configureWindow() {
		JFrame frame = new JFrame("Gauge");

		frame.getContentPane().add(value);
		frame.getContentPane().add(button);
		frame.getContentPane().add(log);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	@Override
	public void update(String v) {
		value.setText(v);
	}

	@Override
	public String getCurVarToShow() {
		return value.getText();
	}

}
